﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using IceDog.DNC.Web.Swashbuckle1_X.CustomAttribute;
using IceDog.DNC.Web.Swashbuckle1_X.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace IceDog.DNC.Web.Swashbuckle1_X.Controllers
{
    /// <summary>
    /// 
    /// </summary>
    [Produces("application/json")]
    [Route("api/Book")]
    [ApiExplorerSettings(GroupName = "v2",IgnoreApi =false)]//通过api版本名进行控制api是否显示
    public class BookController : Controller
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="searchParams"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult Search([FromQuery]SearchParams searchParams)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }
            else
            {
                return Ok();
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet("GetBookById")]
        [Obsolete]//过时
        public Book GetBookById([FromQuery]int id)
        {
            return new Book()
            {
                Id = "B001",
                Name = "软技能 代码之外的生存指南",
                Author = "John Z.Sonmez",
                Price = 56.60M,
                ISBN = "9787115429476",
                Remark = "[美] 约翰 Z.森梅兹（John Z.Sonmez） 著，王小刚 译"
            };
        }
    }
}